<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<script type="text/javascript" >

$(function(){
	$('#processGrid').datagrid({
	    url: ctx + '/wfc/Process!findByPage.action',
	    singleSelect: true,
	    fit: true,
	    toolbar:'#button_index',
	    pagination: true,
	    rownumbers: true,
	    idField: 'sid',
	    onDblClickRow :function(rowIndex,rowData){
	    	CQOA.load('extendDiv',ctx+'/wfc/Process!operate.action',{'entity.sid':rowData.sid},function(){
				CQOA.hideDiv('mainDiv');
				CQOA.showDiv('extendDiv');
			});
	    }
	});
	
	
	$('#processAdd').bind('click',function(){
		CQOA.load('extendDiv',ctx+'/wfc/Process!operate.action',{},function(){
			CQOA.hideDiv('mainDiv');
			CQOA.showDiv('extendDiv');
		});
	});
	$('#processEdit').bind('click',function(){
		var row = $('#processGrid').datagrid('getSelected');
		if (!row) {
			$.messager.show({
				msg : '请选择一条数据'
			});
			return false;
		}
		CQOA.load('extendDiv',ctx+'/wfc/Process!operate.action',{'entity.sid':row.sid},function(){
			CQOA.hideDiv('mainDiv');
			CQOA.showDiv('extendDiv');
		});
	});
	$('#processDel').bind('click',function(){
		var row = $('#processGrid').datagrid('getSelected');
		if (!row) {
			$.messager.show({
				msg : '请选择一条数据'
			});
			return false;
		}
		$.messager.confirm('提示信息','你确定要删除这条数据?',function(s){
			if(s){
				postcommit(ctx+'/wfc/Process!delete.action',{'entity.sid':row.sid},function(o){
					if(o.success){
						$('#processGrid').datagrid("unselectAll");
						$('#processGrid').datagrid('reload');
					}
					$.messager.show({
						msg : o.msg
					});
				});
			}
		});
	});
	
	$('#processDraw').bind('click',function(){
		var row = $('#processGrid').datagrid('getSelected');
		if (!row) {
			$.messager.show({
				msg : '请选择一条数据'
			});
			return false;
		}
		CQOA.load('extendDiv',ctx+'/wfc/Process!draw.action',{'entity.sid':row.sid},function(){
			CQOA.hideDiv('mainDiv');
			CQOA.showDiv('extendDiv');
		});
	});
	
	/**
	$('#userSearch').bind('click',function(){
		$('#processGrid').datagrid('reload',{
			'entity.cname':$('#searchCname').val()
		});
	});
	
	$('#userReset').bind('click',function(){
		$('#searchCname').val('');
	});
	*/
	
	$('#scname').searchbox({
	    searcher:function(value,name){
	    	$('#processGrid').datagrid('reload',{
	    		'entity.cname':value
	    	});
	    },
	    prompt:'请输入岗位名称'
	});
});


function comeback(){
	CQOA.hideDiv('extendDiv');
	CQOA.showDiv('mainDiv');
};

function process_save(){
	CQOA.formSubmit($('#processOperateForm'),ctx+'/wfc/Process!save.action',function(o){
		if(o.success){
			comeback();
			$('#processGrid').datagrid('reload');
		}
		$.messager.show({
			msg : o.msg
		});
	},{});
};

</script>
<div id="mainDiv" class="easyui-layout" fit="true" border="false">
	        <div id="easyui-title" style="display:none">
	            	流程绘制
	        </div>
            <div class="searchDiv" region="north" border="false" style="text-align: center;">
            		<input id="scname" style="width:300px" ></input>
            </div>
            <div id="button_index" class="top_toolbar_button_div" border="false">
                    <a href="#" class="easyui-linkbutton" iconCls="icon-add" id="processAdd">新增</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" id="processEdit">修改</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" id="processDel">删除</a>
                    <a href="#" class="easyui-linkbutton"  id="processDraw">绘制流程</a>
            </div>
            <div  region="center" border="false">
	           <table id="processGrid" title="流程定义" border="false" fit="true" >
	               			<thead>
			                   <tr>
			                      <!-- <th field="sid"  width="50">SID</th> -->
			                      <th field="cname"  width="200">流程名称</th>
			                      <th field="orderBy"  width="200">排序号</th>
			                   </tr>
	               			</thead>
	       	 	</table>
           </div>
</div>
<div id="extendDiv" class="easyui-panel" style="display:none;" fit="true" border="false"></div>
<div id="targetPopup" modal="true" class="easyui-window" closed="true" style="height: 480px; width: 700px" title="选择人员"></div>


